//
//  InformDetailsCell.m
//  Village
//
//  Created by 程虎 on 2017/9/13.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "InformDetailsCell.h"

@implementation InformDetailsCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellID1 = @"InformDetailsCell";
    InformDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID1];
    return cell;
}

- (void)setModel:(InformModel *)model
{
    _model = model;
//    [self.iconImg sd_setImageWithURL:[NSURL URLWithString:[Globle getInstance].headImg] placeholderImage:[UIImage imageNamed:@"user_icon"]];
    self.iconImg.image = [UIImage imageNamed:@"user_icon"];
    self.nameLab.text = _model.userflag;
    NSString *times = _model.baktime;
    if (times.length > 16) {
        times = [times substringWithRange:NSMakeRange(0, 10)];
    }
    self.timesLab.text = [NSString stringWithFormat:@"%@ %@",_model.cnname,times];
    self.contentLab.text = _model.bak;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    CGFloat left = 15;
    CGFloat top = 15;
    
    LRViewRadius(self.iconImg, 20, 0.5, K_LineColor);
    
    self.iconImg.sd_layout
    .leftSpaceToView(self.contentView, left)
    .topSpaceToView(self.contentView, top)
    .widthIs(40)
    .heightEqualToWidth();
    
    self.nameLab.sd_layout
    .leftSpaceToView(self.iconImg, 10.5)
    .topEqualToView(self.iconImg)
    .rightSpaceToView(self.contentView, left)
    .heightIs(20);
    
    self.timesLab.sd_layout
    .leftEqualToView(self.nameLab)
    .topSpaceToView(self.nameLab, 7)
    .rightSpaceToView(self.contentView, left)
    .autoHeightRatio(0);
    
    self.contentLab.sd_layout
    .leftEqualToView(self.iconImg)
    .topSpaceToView(self.iconImg, 14)
    .rightEqualToView(self.timesLab)
    .autoHeightRatio(0);
    
    self.line.sd_layout
    .leftEqualToView(self.contentLab)
    .topSpaceToView(self.contentLab, 17.5)
    .rightEqualToView(self.contentLab)
    .heightIs(0.5);
    
    [self setupAutoHeightWithBottomView:self.line bottomMargin:0];
}

@end
